#!/usr/bin/env bash
set -e
if [[ $1 == "-h" ]]; then
    h h gitup
    exit 0
fi
echo "本脚本用于将修改内容一次性上传gitee。"
echo "请检查是否提供注释，若无注释请重写命令。"

read -r -p "请问是否继续？[y/n]" input
if [[ $input != "y" ]]; then
    echo "已取消上传。"
    exit 0
fi
#currentbranch=`git branch --show-current`
case $1 in
    latex)
        git switch dev
        git add .
        git commit -m $2
        git switch master
        git merge dev
        git push
        git switch dev
        ;;
    *)
        if [[ $PWD =~ $HOME/study/gitee/latex$ || $PWD =~ $HOME/study/gitee/latex/ ]];then
            echo -e "请检查这是否latex仓库，如果是请运行：\e[33mgitup latex\e[0m"
            exit 2
        fi
        git add .
        git commit -m $1
        git push
        ;;
esac
unset input
